package com.saturn.action.system.dict.test;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.saturn.app.utils.BeanUtils;
import com.saturn.app.web.DictManager;
import com.saturn.app.web.IAction;
import com.saturn.app.web.IView;
import com.saturn.app.web.view.JspErrorView;
import com.saturn.app.web.view.JspView;
import com.saturn.system.DictTest;

public class AddDictTestAction implements IAction {

	@Override
	public IView execute(HttpServletRequest request,
			HttpServletResponse response) {

		DictTest dictTest = BeanUtils.getBean(request, DictTest.class);
		dictTest.setTest1Name(DictManager.get().get("2").get(
				dictTest.getTest1()));
		dictTest.setTest2Name(DictManager.get().get("type").get(
				dictTest.getTest2()));
		dictTest.setTest3Name(DictManager.get().get(dictTest.getTest2()).get(
				dictTest.getTest3()));
		dictTest.setTest4Name(DictManager.get().get(dictTest.getTest3()).get(
				dictTest.getTest4()));

		if (DictTest.add(dictTest) == 1) {
			return new JspView("/system/dict/test/showDictTest.jsp");
		} else {
			return new JspErrorView("添加数据字典失败");
		}
	}

	@Override
	public String requestMapping() {
		return "/system/dict/addDictTest.action";
	}

}
